/*
Copyright 2005-2014 CP Fricano - All Rights Reserved

This software and source code is licensed under the Apache
License, Version 2.0. You may not use this software or source
code except in compliance with the License.  You may obtain a
copy of the License at: http://www.apache.org/licenses/LICENSE-2.0.
Use and distributed under this License is on an "as is" basis,
without expressed or implied warranties or conditions of any kind.
See the License for the specific language governing permissions and
limitations.
 */

package com.fricano.java42.swing.dings.tester;

import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.fricano.java42.base.components.helper.Helper_ImageIO;
import com.fricano.java42.base.components.preferences.PreferencesManager;
import com.fricano.java42.swing.dings.components.J42JWindow_Managable;
import com.fricano.java42.swing.dings.components.J42JWindow_Managable.J42JWindow_Manager;
import com.fricano.java42.swing.dings.components.impl.J42SwingDing_TouchTonePad;
import com.fricano.java42.utility.base.Utility_Base;

public class J42SwingDing_TouchTonePadTest_01 extends JPanel {

    private static final long          serialVersionUID = 1L;

    private final static Class<?>      appClass         = J42SwingDing_TouchTonePad.class;

    private static Map<String, String> map              = new HashMap<>();
    private static String              appName          = "TouchTone Pad";
    private static String              appVersion       = "v000";

    static public void main(final Map<String, String> mapIn, final String[] args) throws Exception {

        map = mapIn;
        if (map != null) {
            String s = map.get(Utility_Base.APP_NAME);
            appName = s == null ? appName : s;
            s = map.get(Utility_Base.APP_VERSION);
            appVersion = s == null ? appVersion : s;
        }
        main(args);
    }

    public static void main(final String[] args) {

        final J42SwingDing_TouchTonePad touchTonePad_1 = new J42SwingDing_TouchTonePad(appName, appVersion);
        //final J42SwingDing_TouchTonePad touchTonePad_2 = new J42SwingDing_TouchTonePad(appName, appVersion);

        JFrame jFrame = null;
        if (true) {
            jFrame = new J42JWindow_Managable();
        }
        else {
            jFrame = new JFrame();
        }

        final URL url = J42SwingDing_TouchTonePad.class.getClassLoader().getResource("images/redphone.png");
        jFrame.setIconImage(Helper_ImageIO.getInstance().loadImage(BufferedImage.class, url));
        jFrame.setTitle(appName + " " + appVersion);

        if (jFrame instanceof J42JWindow_Managable) {
            final J42JWindow_Manager manager = ((J42JWindow_Managable) jFrame).getManager();
            manager.enableFrameButtonLeft(false);
            manager.enableResizable(false);
            manager.enableManagedClientBorder(false);
            manager.enableGlassPaneControls(false);
        }

        jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        jFrame.setUndecorated(true);

        final JPanel jPanel = new JPanel(new GridLayout(1, 1));
        jPanel.add(touchTonePad_1);
        //jPanel.add(touchTonePad_2);
        jFrame.setContentPane(jPanel);

        jFrame.setSize(350, 350);
        final Dimension dimension = jFrame.getSize();
        jFrame.setLocationRelativeTo(null);

        PreferencesManager.getInstance(true, appClass).restoreComponent(jFrame, null);

        jFrame.setSize(dimension);

        jFrame.setVisible(true);

    }
}
